package model.agent.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import model.agent.entity.Agent;
import model.agent.entity.Result;
import model.agent.service.IAgentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by Administrator on 2019/6/25.
 */
@RestController
public class NewAgentController {
    @Autowired
    private IAgentService iAgentService;
    @CrossOrigin
    @GetMapping("/agent/{pageNow}")
    public Result list(@PathVariable("pageNow") String pageNow){

        Integer pg=Integer.parseInt(pageNow);
        PageHelper.startPage(pg,6);
        List<Agent> agentList=iAgentService.findall();
        PageInfo<Agent> pageInfo=new PageInfo<>(agentList);
        Result result = new Result(true,20000,"查询成功",agentList);

        return  result;
    }
//    @CrossOrigin
//    @GetMapping("/agent")
//    public Result find(){
//
//        List<Agent> agentList=iAgentService.findall("");
//
//        Result result = new Result(true,20000,"查询成功",agentList);
//        return result;
//    }
//    @CrossOrigin
//    @GetMapping("/newagent/{address}")
//    public Result findaddrssslist(@PathVariable("address")String address){
//
//        List<Agent> agentList=iAgentService.getByAddress(address);
//        Result result = new Result(true,20000,"查询成功",agentList);
//        return result;
//    }
//    @CrossOrigin
//    @GetMapping("/newagent")
//    public Result findaddrsss(){
//
//        List<Agent> agentList=iAgentService.getByAddress("");
//        System.out.println(agentList);
//        Result result = new Result(true,20000,"查询成功",agentList);
//        System.out.println(result);
//        System.out.println(result.getData());
//        return result;
//    }
}
